-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: permit2: write a permit2 router #420
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jkrivine
requested changes
Jul 28, 2023
This reverts commit 0227821.
Closing this at is has been migrated to the new mangrove-strats repo: mangrovedao/mangrove-strats#13 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In this pull request (PR), I integrated the Permit2 contract from Uniswap into our
MangroveOrder
contract. To achieve this, I created a new contract calledPermit2Router
, which inherits from theSimpleRouter
implementation. The primary change is in thepull
function. Within thepull
function, I utilizedPermit2
to facilitate fund transfers using the Permit2 contract. To enable this functionality, users' EOAs must call theapprove
function on the Permit2 contract to grant permission to thePermit2Router
to withdraw funds on their behalf. Additionally, users have the option to generate an off-chain Transfer signature that authorizes the contract specified in the signature to perform a one-time fund withdrawal from their EOA instead of callingapprove.
The new use cases of
MangroveOrder
are as follows:MarketOrder
: This type of order utilizes themarketOrderWithTransferApproval
function. In this scenario, theMangroveOrder
contract pulls the specified amount ofinbound_tkn
from themsg.sender
using just-in-time one-time approval. Subsequently, it executes a market order and returns any unused funds back to the user.LimitOrder
withtakeWithPermit
: When using this function, a user initiates an off-chain permit signature, which is sent to the Permit2 contract to authorize theMangroveOrder
router to withdraw funds from the Permit2 contract. After this, the function calltake
and initiate a limit order.LimitOrder
withtake
: Similar to the previous case, the user callspermit
orapprove
to the Permit2 contract beforehand. After this, they can do aLimitOrder
by callingtake
.These modifications expand the functionalities of
MangroveOrder
to permit the users to approve once by token by chain the permit2 contract, instead of approving once by token by contract that needs to pull the funds.